package com.by.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    private static int SUCCESS=200; //代表成功的状态码
    private static int FAIL=0; //代表失败的状态码

    public static <T> Result<T> success(String msg){
        return new Result<T>(SUCCESS,msg,null);
    }

    public static <T> Result<T> success(String msg,T data){
        return new Result<T>(SUCCESS,msg,data);
    }

    public static <T> Result<T> fail(String msg){
        return new Result<T>(FAIL,msg,null);
    }
}
